/* Turska Framework/UI library (Turs2)
 * Copyright 2003-2010 Jetro Lauha
 * All rights reserved.
 * Web: http://iki.fi/jetro/turska/
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of EITHER:
 *   (1) The GNU Lesser General Public License as published by the Free
 *       Software Foundation; either version 2.1 of the License, or (at
 *       your option) any later version. The text of the GNU Lesser
 *       General Public License is included with this library in the
 *       file LICENSE-LGPL.txt.
 *   (2) The BSD-style license that is included with this library in
 *       the file LICENSE-BSD.txt.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
 * LICENSE-LGPL.txt and LICENSE-BSD.txt for more details.
 *
 * $Id: T2IMGUIImageTextFieldStyle.h 200 2011-08-05 02:56:16Z jlauha $
 * $Revision: 200 $
 */

#ifndef T2IMGUIIMAGETEXTFIELDSTYLE_H_INCL
#define T2IMGUIIMAGETEXTFIELDSTYLE_H_INCL


namespace turska
{
    //! Image text field with fixed extents defined by the image size.
    /*! The width and height are ignored when there's an image to use.
     */
    class IMGUIImageTextFieldStyle : public IMGUITextFieldStyle
    {
    public:
        IMGUIImageTextFieldStyle(Font *font, Image *caretImage, Image *imageUp,
                                 Image *imageHot, Image *imageActive);

        // From IMGUITextFieldStyle:

        virtual bool isInside(const IMGUI &imgui, TREAL x, TREAL y,
                              const Rectangle &area);

        virtual bool isCharAllowed(UI32 character);

        virtual Rectangle render(const IMGUI &imgui, I32 widgetState,
                                 TREAL x, TREAL y, TREAL width, TREAL height,
                                 const C8 *text);

        // Local

        void setScale(TREAL scale) { mScale = scale; }
        void setTextFieldColor(const Color &color) { mTextFieldColor = color; }
        void setTextColor(const Color &color) { mTextColor = color; }
        void setCaretColor(const Color &color) { mCaretColor = color; }
        void setFont(Font *font) { mFont = font; }
        void setTextOffset(TREAL offsetX, TREAL offsetY) { mTextOffsetX = offsetX; mTextOffsetY = offsetY; }
        void setTextScale(TREAL textScale) { mTextScale = textScale; }

        TREAL getWidth() { return mScale * mImageWidth; }
        TREAL getHeight() { return mScale * mImageHeight; }

    protected:
        TREAL mScale;
        Color mTextFieldColor;
        Color mTextColor;
        Color mCaretColor;
        Image *mCaretImage;
        Image *mImages[IMGUI_WS_COUNT];
        UI32 mImageWidth, mImageHeight;
        Font *mFont;
        TREAL mTextOffsetX, mTextOffsetY;
        TREAL mTextScale;
    };

} // namespace turska


#endif // !T2IMGUIIMAGETEXTFIELDSTYLE_H_INCL
